package blackstar.performance;

import java.lang.management.ManagementFactory;
import java.util.logging.Logger;

import javax.management.MBeanServer;
import javax.management.ObjectName;

public class MBeanRegister
{
	private final static Logger LOGGER = Logger.getLogger(MBeanRegister.class
			.getSimpleName());

	public final static String DOMAIN = "BlackStar";

	public static void registMBean(String name, Object bean)
	{
		String beanName = DOMAIN + ":" + name;
		MBeanServer server = ManagementFactory.getPlatformMBeanServer();
		try
		{
			server.registerMBean(bean, new ObjectName(beanName));
			LOGGER.info("Regist Bean[" + bean + "] Bean with Name[" + DOMAIN
					+ ":" + name + "] Success");
		} catch (Exception e)
		{
			LOGGER.warning("Regist Bean[" + bean + "] Bean with Name["
					+ beanName + "] Failed:" + e.getMessage());
		}
	}
}
